package com.zx.security.block.context;

import org.springframework.security.core.Authentication;

/**
 * <p>
 * description: 身份认证上下文 <br>
 * create: 2024-08-22 14:40 <br>
 * </p>
 *
 * @author zhou  xun
 */
public class AuthenticationContextHolder {
    private static final ThreadLocal<Authentication> CONTEXT_HOLDER = new ThreadLocal<>();

    public static Authentication getContext() {
        return CONTEXT_HOLDER.get();
    }

    public static void setContext(Authentication context) {
        CONTEXT_HOLDER.set(context);
    }

    public static void clearContext() {
        CONTEXT_HOLDER.remove();
    }
}
